package com.lmx.repoDomain.tmodel;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.fasterxml.jackson.annotation.JsonIgnore;

import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;

@JsonApiResource(type = "typegroup")
@Entity
@Table(name = "t_s_typegroup")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Typegroup extends BaseEntity {

	public static Map<String, Typegroup> allTypeGroups = new HashMap<String, Typegroup>();

	public static Map<String, List<Dicttype>> allTypes = new HashMap<String, List<Dicttype>>();

	private String typegroupcode;// 分组编码

	private String typegroupname;// 分组名称

	private List<Dicttype> types = new ArrayList<Dicttype>();

	private String remark;// 备注

//	private String flagRemark;// 备注 区分 移动端 pc 公众号 共用
//
//	@Column(name = "flag_remark")
//	public String getFlagRemark() {
//		return flagRemark;
//	}
//
//	public void setFlagRemark(String flagRemark) {
//		this.flagRemark = flagRemark;
//	}

	@Column(name = "typegroupname", length = 50)
	public String getTypegroupname() {
		return this.typegroupname;
	}

	public void setTypegroupname(String typegroupname) {
		this.typegroupname = typegroupname;
	}

	@Column(name = "typegroupcode", length = 50)
	public String getTypegroupcode() {
		return this.typegroupcode;
	}

	public void setTypegroupcode(String typegroupcode) {
		this.typegroupcode = typegroupcode;
	}

	@JsonApiToMany
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "typegroup")
	@JsonIgnore
	public List<Dicttype> getTypes() {
		return this.types;
	}

	public void setTypes(List<Dicttype> types) {
		this.types = types;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}